package com.hbm.usercenter.holder;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.hbm.usercenter.R;
import com.hbm.usercenter.base.BaseHolder;
import com.hbm.usercenter.bean.OrderBean;
import com.hbm.usercenter.utils.UIUtils;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by BS on 2017/6/20.
 */

public class OrderHolder extends BaseHolder<OrderBean.RowsBean> {
    @Bind(R.id.tv_order_sn)
    TextView mTvOrderSn;
    @Bind(R.id.iv_icon)
    ImageView mIvIcon;
    @Bind(R.id.tv_name)
    TextView mTvName;
    @Bind(R.id.tv_attr)
    TextView mTvAttr;
    @Bind(R.id.tv_price)
    TextView mTvPrice;
    @Bind(R.id.tv_real_price)
    TextView mTvRealPrice;
    private final String PICURL = "http://image.huibaoming.cn/";
    @Bind(R.id.tv_play_status)
    TextView mTvPayStatus;
    @Bind(R.id.tv_number)
    TextView mTvNumber;
    @Bind(R.id.real_price)
    TextView mRealPrice;


    @Override
    protected View initHolderView() {
        View view = View.inflate(UIUtils.getContext(), R.layout.item_order, null);
        ButterKnife.bind(this, view);

        return view;
    }

    @Override
    protected void refreshHolderView(OrderBean.RowsBean data) {
        OrderBean.RowsBean.ItemRowsBean datas = data.item_rows.get(0);
        mTvOrderSn.setText(datas.order_sn);
        mTvName.setText(datas.name);
        mTvAttr.setText(datas.attr_str);
        mTvPrice.setText(datas.price + "");
        mTvRealPrice.setText(datas.real_price + "");
        mTvNumber.setText(datas.number+"");
        int pay_status = datas.pay_status;
        switch (pay_status) {
            case 0:
                mTvPayStatus.setText("已关闭");
                break;
            case 2:
                mTvPayStatus.setText("已支付");
                break;

        }
        UIUtils.getPicasso().with(UIUtils.getContext()).load(PICURL+datas.icon).into(mIvIcon);
    }

}
